// let baseUrl = 'https://youxin.hopernet.com:9572/api'
let baseUrl = 'https://rrbstest.hopernet.com:20010/api'
// let baseUrl = "http://192.168.1.64:9565"
// let baseUrl = "http://192.168.1.178:9565"

const request = params => {
  //console.log(baseUrl + params.url);
  if (params.isLoading) {
    wx.showLoading({
      title: '加载中...', 
    })
  }
  wx.request({
    url: baseUrl + params.url,
    method: params.method || 'get',
    data: params.data || {},
    header: params.header || {},
    success(res) {
      wx.hideLoading()
      if (params.success) {
        params.success(res.data)
      }

    },
    fail(err) {
      wx.hideLoading()
      if (params.fail) {
        params.fail(err)
      }
    },
  })
}

module.exports = request